package com.nf.service;

import com.nf.entity.GirlWcManInfo;
import com.nf.entity.User;
import com.nf.mapper.ToiletMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class ToiletServiceImpl implements ToiletService {
    private ToiletMapper toiletMapper=null;
    public User text() {
        SqlSession session=null;

        try {
            InputStream inputStream= Resources.getResourceAsStream("mybatis-comfig.xml");
            SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
            session= sqlSessionFactory.openSession();
            toiletMapper =session.getMapper(ToiletMapper.class);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }

        List<User> users = toiletMapper.getAllUser();
        System.out.println("一、全人类！");
        for (User s:users) {
            System.out.println(s.getId()+"  "+s.getUserName()+" "+s.getSex());
        }

        List<GirlWcManInfo> girlWcManInfos=toiletMapper.getAllGirlWcManInfo();
        System.out.println();
        System.out.println("二、在女厕所的死变态！");
        for (GirlWcManInfo g:girlWcManInfos){
            System.out.print(g.getWcName()+"  "+g.getUserName()+" "+g.getSex());
        }
        return null;
    }
}
